package com.ocom.human.controller;

import com.ocom.common.constant.HumanServiceUrl;
import com.ocom.common.entity.master.EntityWechatAppInfo;
import com.ocom.common.entity.master.EntityWechatPerInfo;
import com.ocom.common.resp.Result;
import com.ocom.common.utils.ResultUtil;
import com.ocom.human.service.WechatAppInfoService;
import com.ocom.human.service.WechatPerInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
public class CardInfoController {

    @Autowired
    private WechatAppInfoService wechatAppInfoService;

    @Autowired
    private WechatPerInfoService wechatPerInfoService;

    @GetMapping(HumanServiceUrl.URL_getCardInfoByUser)
    public Result getCardInfoByUser(Long companyId, Long userId){
        //2、从总库微信账户表wechat_app_info查找app_name=”ocom2.0”的appid值，再从总库微信人员表wechat_per_info查找appid、com_id、p_id匹配的记录，
        String appName="ocom2.0";
        EntityWechatAppInfo appOcom2Info = wechatAppInfoService.getAppOcom2Info(appName);
        if (appOcom2Info == null){
            return null;
        }
        String appid = appOcom2Info.getAppid();
        EntityWechatPerInfo wechatPerInfo = wechatPerInfoService.getWechatPerInfo(companyId, userId, appid);
        if (wechatPerInfo == null){
            return null;
        }
        List<EntityWechatPerInfo> cardInfo = new ArrayList<>();


        return ResultUtil.success();
    }
}
